//
//  ViewController.m
//  Chara
//
//  Created by student on 16/3/17.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

{
    CGPoint pointXY;
}
@property (weak, nonatomic) IBOutlet UIImageView *imageView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    NSMutableArray *arr = [NSMutableArray array];
    UIImage *image1 = [UIImage imageNamed:@"chara1"];
    UIImage *image2 = [UIImage imageNamed:@"chara2"];
    [arr addObject:image1];
    [arr addObject:image2];
    self.imageView.animationImages = arr;
    self.imageView.animationDuration = 0.5;
    [self.imageView startAnimating];
    
//    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panDo:)];
//    [self.view addGestureRecognizer:pan];
    
}

//- (void)panDo:(UIPanGestureRecognizer *)p
//{
//    CGPoint tran = [p translationInView:self.view];
//    CGPoint center = self.imageView.center;
//    self.imageView.center = CGPointMake(center.x+tran.x, center.y+tran.y);
//    [p setTranslation:CGPointZero inView:self.view];
//}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint curpoint = [touch locationInView:self.view];
//    CGPoint center = self.imageView.center;
    self.imageView.center = CGPointMake(curpoint.x+pointXY.x, curpoint.y+pointXY.y);
}
@end
